<template>
	<view>
		<view class="main">
			<view class="total" :class="'bgColor' + type">
				<view class="top">
					<u-icon name="integral" color="#F7F7F7" size="35" @click="look"></u-icon>
					<text>总收益统计</text>
				</view>
				<view class="bottom">
					<view class="bottom-item one border-right">
						<view class="number">
							<text>{{total.all_total}}</text>
						</view>
						<view class="title">
							<text>总收益</text>
						</view>
					</view>
					<view class="bottom-item two border-right">
						<view class="number">
							<text>{{total.recorded_total}}</text>
						</view>
						<view class="title">
							<text>已入账</text>
						</view>
					</view>
					<view class="bottom-item three">
						<view class="number">
							<text>{{total.norecorded_total}}</text>
						</view>
						<view class="title">
							<text>未入账</text>
						</view>
					</view>
				</view>
			</view>
			<view v-if="lists.length > 0" class="list">
				<view class="item" v-for="(item, index) in lists" :key="index" @click="dayClick(item.date)">
					<view class="left">
						<view class="title">
							<text>{{item.date_cn}}</text>
						</view>
						<view class="money">
							<text>收益：</text>
							<text>{{item.total}}</text>
						</view>
					</view>
					<view class="right">
						<text v-if="item.state == 1" class="reds">未入账</text>
						<text v-else class="greens">已入账</text>
						<u-icon name="arrow-right" color="#6574bc" size="20"></u-icon>
					</view>
				</view>
			</view>
			<u-empty v-else mode="list" icon="/static/Empty/data_null.png">
			</u-empty>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				type: 1,
				total: {},
				lists: [],
				date: '',
			}
		},
		onLoad(e) {
			this.type = e.type
			this.loadData()
			this.getUserBalanceTotalList()
		},
		methods: {
			// 详情
			dayClick(dates) {
				uni.navigateTo({
					url: '/pages/hzy/cash/total/days?type=' + this.type + '&date=' + dates
				})
			},
			async loadData() {
				uni.showLoading({
					title: '加载中'
				});
				const {
					data: res
				} = await this.$myHttp({
					url: 'v1/getUserBalanceTotal',
					data: {
						type: this.type,
						date: this.date
					}
				});
				uni.hideLoading()
				if (res.code == 200) {
					this.total = res.data
				}
			},
			// 加载列表
			async getUserBalanceTotalList() {
				const {
					data: res
				} = await this.$myHttp({
					url: 'v1/getUserBalanceTotalList',
					data: {
						type: this.type,
						date: this.date
					}
				});
				if (res.code == 200) {
					this.lists = res.data
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.main {

		.total {
			margin: 30rpx;
			padding: 30rpx;
			color: #ffffff;
			border-radius: 20rpx;
			box-shadow: 0px 5px 20px -10px #342f2f;

			.top {
				display: flex;
				align-items: center;

				text {
					font-size: 38rpx;
					padding-left: 16rpx;
				}
			}

			.bottom {
				margin-top: 40rpx;
				font-size: 24rpx;
				display: flex;
				text-align: center;
				align-items: center;

				.number {
					font-size: 28rpx;
					font-weight: bold;
					margin-bottom: 10rpx;
				}

				.title {
					padding-bottom: 6rpx;
				}

				.bottom-item {
					width: 33.3%;
				}

				.border-right {
					border-right: 1px solid #d1d5e3;
				}
			}
		}

		.list {
			margin-top: 50rpx;
			background-color: #ffffff;

			.item {
				padding: 30rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;
				border-bottom: 1px solid #d1d5e3;

				.title {
					font-weight: bold;
				}

				.money {
					padding-top: 10rpx;
					font-size: 28rpx;
					color: #909399;
				}

				.right {
					display: flex;

					text {
						margin-right: 30rpx;
						padding: 10rpx 30rpx;
						color: #ffffff;
						border-radius: 20rpx;
						font-size: 24rpx;
					}

					.reds {
						background-color: #fa3534;
					}

					.greens {
						background-color: #19be6b;
					}
				}
			}
		}

		.bgColor1 {
			background-color: #2979ff;
		}

		.bgColor2 {
			background-color: #fa3534;
		}

		.bgColor3 {
			background-color: #ff9900;
		}

		.bgColor4 {
			background-color: #19be6b;
		}

		.bgColor5 {
			background-color: #A600A9;
		}
	}
</style>